<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Component 标签</title>
  </head>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
  <body>
    <h1>Hello Component 标签</h1>
    <hr />
    <div id="app">
      {{message}}
      <component :is="who"></component>
    </div>
  </body>

  <template id="tmp1">
    <div style="color:red">我是组件1</div>
  </template>
  <template id="tmp2">
    <div style="color:red">我是组件2</div>
  </template>
  <template id="tmp3">
    <div style="color:red">我是组件3</div>
  </template>

  <script>
    var componentA = {
      template: '#tmp1'
    }
    var componentB = {
      template: '#tmp2'
    }
    var componentC = {
      template: '#tmp3'
    }
    var app = new Vue({
      el: '#app',
      data: {
        message: 'Hello Vue',
        who: 'componentA'
      },
      components: {
        componentA: componentA,
        componentB: componentB,
        componentC: componentC
      }
    })
  </script>
</html>
